package com.hornsun.util;

import java.io.FileInputStream;
import java.io.IOException;
import java.security.DigestInputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Date;
import java.util.Random;
import java.util.regex.Pattern;

/**
 * Created by 编译中... on 2018/1/4.
 */
public class StrUtil {

    public static final String SECRET_KEY = "(@^@)Hornsun!2017";

    /**
     * 字符串后加“ desc”
     * @param str
     * @return
     */
    public static String toDesc(String str){
        str+=" desc";
        return str;
    };

    /**
     * 判断字符串是否为电话号码
     * @param str
     * @return
     */
    public static boolean isPhoneNumber(String str) {
        final String REGEX_MOBILE = "^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$";

        return Pattern.matches(REGEX_MOBILE, str);
    }

    //获取6位随机数
    public static String random(){
        Random random = new Random();
        String result="";
        for (int i=0;i<6;i++)
        {
            result+=random.nextInt(10);
        }
        return result;
    }

    public static String toSystem(String str){
        String android = "Android";
        String ios = "iOS";
        if (str.contains(android)){
            return android;
        }else if(str.contains(ios)){
            return ios;
        }else {
            return str;
        }
    }





}
